﻿@model IList<Nop.Web.Models.ShoppingCart.ShoppingCartModel.CheckoutAttributeModel>
@using Nop.Core.Domain.Catalog;
@if (Model.Count > 0)
{
    <div class="checkout-attributes">
        <dl id="msgId">
            @foreach (var attribute in Model)
            {
                string controlId = string.Format("checkout_attribute_{0}", attribute.Id);
                string textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
                string name = attribute.Name.ToLower();
                bool giftmessageFlag = name.Equals("sender") || name.Equals("receiver") || name.Equals("message");
                if (!giftmessageFlag) { continue; }

                <dt>
                    @if (attribute.IsRequired)
                    {
                        <span class="required">*</span>
                    }
                </dt>
                <dd>
                    @switch (attribute.AttributeControlType)
                    {
                        case AttributeControlType.TextBox:
                            {
                                <div class="col-xs-6">
                                    <label class="text-prompt" for="@(controlId)">
                                        @textPrompt
                                    </label>
                                    <input name="@(controlId)" type="text" placeholder="@if(textPrompt.ToLower() == "sender name"){<text>Your Name</text>}else if (textPrompt.ToLower() == "receiver name"){<text>Receiver Name</text>}" class="textbox @(giftmessageFlag?"gitMessage":"") form-control" id="@(controlId)" @(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? " value=" + attribute.DefaultValue : null) />
                                </div>
                            }
                            break;
                        case AttributeControlType.MultilineTextbox:
                            {
                                <div class="col-xs-12">
                                    <label class="text-prompt" for="@(controlId)">
                                        @textPrompt
                                    </label>
                                    <textarea id="@(controlId)" placeholder="Put down what you want to say to the receiver." class="@(giftmessageFlag?"gitMessage":"") form-control" name="@(controlId)">@(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? attribute.DefaultValue : null)</textarea>
                                </div>
                            }
                            break;
                        default:
                            break;
                    }
                </dd>
            }
        </dl>
        <dl>
            @foreach (var attribute in Model)
            {
                string controlId = string.Format("checkout_attribute_{0}", attribute.Id);
                string textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
                string name = attribute.Name.ToLower();
                bool giftmessageFlag = name.Equals("sender") || name.Equals("receiver") || name.Equals("message");
                if (giftmessageFlag) { continue; }
                <dt>
                    <span class="text-prompt">
                        @textPrompt
                    </span>
                    @if (attribute.IsRequired)
                    {
                        <span class="required">*</span>
                    }
                </dt>
                <dd>
                    @switch (attribute.AttributeControlType)
                    {
                        case AttributeControlType.DropdownList:
                            {
                                <select name="@(controlId)" id="@(controlId)">
                                    @if (!attribute.IsRequired)
                                    {
                                        <option value="0">---</option>
                                    }
                                    @foreach (var caValue in attribute.Values)
                                    {
                                        <option selected="@caValue.IsPreSelected" value="@caValue.Id">
                                            @caValue.Name
                                            @(!String.IsNullOrEmpty(caValue.PriceAdjustment) ? " [" + caValue.PriceAdjustment + "]" : null)
                                        </option>
                                    }
                                </select>
                            }
                            break;
                        case AttributeControlType.RadioList:
                            {
                                <ul class="option-list">
                                    @foreach (var caValue in attribute.Values)
                                    {
                                        <li>
                                            <input id="@(controlId)_@(caValue.Id)" type="radio" name="@(controlId)" value="@caValue.Id" checked="@caValue.IsPreSelected" />
                                            <label for="@(controlId)_@(caValue.Id)">@caValue.Name @(!String.IsNullOrEmpty(caValue.PriceAdjustment) ? " [" + caValue.PriceAdjustment + "]" : null)</label>
                                        </li>
                                    }
                                </ul>
                            }
                            break;
                        case AttributeControlType.Checkboxes:
                            {
                                <ul class="option-list">
                                    @foreach (var caValue in attribute.Values)
                                    {
                                        <li>
                                            <input id="@(controlId)_@(caValue.Id)" type="checkbox" name="@(controlId)" value="@caValue.Id" checked="@caValue.IsPreSelected" />
                                            <label for="@(controlId)_@(caValue.Id)">@caValue.Name @(!String.IsNullOrEmpty(caValue.PriceAdjustment) ? " [" + caValue.PriceAdjustment + "]" : null)</label>
                                        </li>
                                    }
                                </ul>
                            }
                            break;
                        case AttributeControlType.TextBox:
                            {
                                <input name="@(controlId)" type="text" class="textbox" id="@(controlId)" @(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? " value=" + attribute.DefaultValue : null) />
                            }
                            break;
                        case AttributeControlType.MultilineTextbox:
                            {
                                <textarea id="@(controlId)" name="@(controlId)">@(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? attribute.DefaultValue : null)</textarea>
                            }
                            break;
                        case AttributeControlType.Datepicker:
                            {
                                @Html.DatePickerDropDowns(controlId + "_day", controlId + "_month", controlId + "_year", DateTime.Now.Year, DateTime.Now.Year + 1, attribute.SelectedDay, attribute.SelectedMonth, attribute.SelectedYear)
                            }
                            break;
                        case AttributeControlType.FileUpload:
                            {
                                <input type="file" id="@(controlId)" name="@(controlId)" />
                            }
                            break;
                    }
                </dd>
            }
        </dl>
    </div>
}